#include "Parser.h"
#include "../Scanner-Automat/Scanner.h"
#include "../Puffer/Buffer.h"
#include "../Scanner-Automat/Scanner.h"
#include "../Scanner-Automat/Token.h"
#include "../Scanner-Automat/Output.h"

#include <stdio.h>

int main(int argc, char* argv[]) {
	puts("Start");

	if (argc != 3) {
			fprintf(stderr, "Usage: %s INPUTFILE OUTPUTFILE\n", argv[0]);
			return EXIT_FAILURE;
		}

		// prepare buffer
		Buffer buffer;
		if (!buffer.init(argv[1], argv[2])) {
			puts("Cannot initialize Buffer");
			return EXIT_FAILURE;
		}

		// prepare scanner and token
		Scanner* scanner = new ScannerImp(buffer);
		Token outputToken;

	Parser parser(*scanner);
	parser.parse();

	// Additional () to avoid warnings
	while ((scanner->nextToken(outputToken))) {
		output(buffer, outputToken); // Print Token
	}

	// clean up
	delete scanner;

	puts("End");

	return EXIT_SUCCESS;
}

